''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Name: de_ChRight
'
'Comments:
' This function returns the characters to the right of a specified occurance
' (WhatOcc) of a specified identifier (WhatChar) in a string of characters
' (srcString)
'
'In: WhatChar --> The identifier marking the point at which to stop
' reading the source string
' WhatOcc --> The occurance of the identifier to look for
' srcString --> The source string to read in
'
'Out: String of characters
'
'Examples:
' 1. To return the characters to the right of the FIRST SPACE
'
' de_ChRight(" ", 1, "String To Search") returns the string "To Search"
'
' 2. To return the characters to the right of the THIRD #
'
' de_ChRight("#", 3, "#01#02#03#04") returns the string "03#04"
'
'Created:
' 1/22/99 10:11:37 AM by Stephen G. Negus
'
'Modifications:
' Date Author Description
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function de_ChRight(WhatChar As String, WhatOcc As Integer, _
srcString As String) As String
On Error GoTo de_ChRight_Err
Dim strProcedureName As String, intLength As Integer
Dim i As Integer, j As Integer, k As Integer
strProcedureName = "de_ChRight"
intLength = Len(srcString)
k = 0
j = 0
For i = 1 To WhatOcc
j = InStr(k + 1, srcString, WhatChar)
k = j
Next i
intLength = intLength - k
de_ChRight = Mid(srcString, k + 1, intLength)
de_ChRight_Exit:
Exit Function
de_ChRight_Err:
Dim strErrMsg As String
Select Case Err
Case 0 'Insert errors you wish to ignore here
Resume Next
Case Else 'Trap all other errors
Beep
strErrMsg = "Error " & Err.Number & " has occurred. " _
& vbCrLf & vbCrLf
strErrMsg = strErrMsg & "The description is: " & Err.Description
MsgBox strErrMsg, vbExclamation + vbOKOnly, " Error in " _
& Chr(34) & strProcedureName & Chr(34)
Resume de_ChRight_Exit
End Select
End Function
|